package com.cta.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.cta.entity.PBXFactory;
import com.cta.entity.Profile;
import com.cta.entity.ServiceProvider;
import com.cta.entity.Trunk;
import com.cta.exception.CTAServiceException;

public interface ProfileService {

	/**
	 * create provider
	 * 
	 * @param name
	 * @param description
	 */
	public ServiceProvider createServiceProvider(String name, String description);

	/**
	 * update service provider
	 * 
	 * @param serviceProviderId
	 * @param name
	 * @param description
	 * @return
	 */
	@Transactional(readOnly = false)
	public ServiceProvider updateServiceProvider(Long serviceProviderId, String name, String description);

	/**
	 * check name of service provider
	 * 
	 * @param name
	 * @return
	 */
	public boolean hasServiceProviderName(String name);

	/**
	 * find service provider by id
	 * 
	 * @param pbxServiceProviderId
	 * @return
	 */
	public ServiceProvider findServiceProviderById(Long pbxServiceProviderId);

	/**
	 * find all Provider
	 * 
	 * @return
	 */
	public List<ServiceProvider> findAllProviders();

	/**
	 * create trunk
	 * 
	 * @param name
	 * @param description
	 * @return
	 */
	public Trunk createTrunk(String trunkNo, String name, String description, Long serviceProviderId, Long pbxId,
			Long configId);

	/**
	 * update trunk
	 * 
	 * @param trunkId
	 * @param name
	 * @param description
	 * @param serviceProviderId
	 * @param pbxId
	 * @return
	 */
	public void updateTrunk(Long trunkId, String trunkNo, String name, String description, Long serviceProviderId,
			Long pbxId, Long configId);

	/**
	 * find all Trunk
	 * 
	 * @return
	 */
	public List<Trunk> findAllTrunks();

	/**
	 * find list of trunk base on service provider id
	 * 
	 * @param serviceProviderId
	 * @return
	 */
	public List<Trunk> findTrunkByProvider(Long serviceProviderId);

	/**
	 * find trunk base on id
	 * 
	 * @param serviceProviderId
	 * @return
	 */
	public Trunk findTrunkById(Long id);

	/**
	 * create pbx factory
	 * 
	 * @param name
	 * @param description
	 * @return
	 */
	public PBXFactory createPBXFactory(String name, String description);

	/**
	 * update pbx factory
	 * 
	 * @param factoryId
	 * @param name
	 * @param description
	 * @return
	 */
	public PBXFactory editPBXFactory(Long factoryId, String name, String description);

	/**
	 * check if this name has exist on db
	 * 
	 * @param name
	 * @return
	 */
	public boolean hasPBXFactoryName(String name);

	/**
	 * find all pbx factory
	 * 
	 * @return
	 */
	public List<PBXFactory> findAllPBXFactories();

	/**
	 * find pbx factory by id
	 * 
	 * @return
	 */
	public PBXFactory findPBXFactory(Long pbxFactoryId);

	/**
	 * find all profile of pbx and eager load pbx
	 * 
	 * @return
	 */
	public List<Profile> findProfileByPBXId(Long pbxId);
	
	public List<Profile> findProfileByPBXNo(String pbxNo);

	/**
	 * save profile of pbx
	 * 
	 * @param id
	 * @param name
	 * @param description
	 * @param pbxId
	 * @return
	 */
	public void saveProfile(List<Object> profileData, String linefeed, String dateFormat, String durationFormat,
			Long pbxId) throws CTAServiceException;

	/**
	 * delete entity
	 * 
	 * @param profileId
	 */
	public void deleteProfile(Long profileId);

	/**
	 * check name of PBX
	 * 
	 * @param name
	 * @return
	 */
	public boolean hasPBXName(String name);

	/**
	 * check name of Trunk
	 * 
	 * @param name
	 * @return
	 */
	public boolean hasTrunkName(String name);

	/**
	 * check name of user
	 * 
	 * @param name
	 * @return
	 */
	public boolean hasUserName(String name);

}
